import { Component, Prop, Vue } from 'vue-property-decorator'
import router from '../../router/index'

import './trade-list.less'

@Component({
  template: require('./trade-list.html')
})
export default class TradeListComponent extends Vue {
  @Prop({
    default: 'Default Value'
  })
  message: string;

  dialogFormVisible: boolean = false

  form: object = {
    name: '',
    region: '',
    baseMoney: '1000000',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: ''
  }

  formLabelWidth: string = '120px'

  onPushTrade () {
    this.dialogFormVisible = false

    this.$message({
      type: 'success',
      message: '创建成功!'
    });

    router.push({
      name: 'TradeInfo',
      params: {
        id: '1'
      }
    })
  }

  onDeleteTrade () {
    this.$confirm('此操作将永久删除该计划, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    .then(() => {
      this.$message({
        type: 'success',
        message: '删除成功!'
      });
    })
    .catch(() => {
      this.$message({
        type: 'info',
        message: '已取消删除'
      });
    });
  }
}
